package vistas;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;
import javax.swing.SwingUtilities;

import beans.EntidadBean;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class AdministrarProveedores extends BaseJFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7030896646166961016L;
	
	private JLabel LabelTitulo;
	private JButton buttonSalir;
	private JList listaProveedores;
	private JButton buttonModificar;
	private JButton btnAlta;
	private JLabel jLabel1;
	private JButton buttonDetalle;
	private DefaultListModel listModel = new DefaultListModel();

	public AdministrarProveedores() {
		super();
		initGUI();
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Administrar Proveedores" + "");

			{
				LabelTitulo = new JLabel();
				getContentPane().add(LabelTitulo);
				LabelTitulo.setText("Administar Proveedores");
				LabelTitulo.setBounds(106, 12, 199, 16);
				LabelTitulo.setFont(new java.awt.Font("Segoe UI", 0, 14));
			}

			{
				buttonDetalle = new JButton();
				getContentPane().add(buttonDetalle);
				buttonDetalle.setText("Detalle");
				buttonDetalle.setBounds(216, 220, 134, 23);
				buttonDetalle.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						if (listaProveedores.getSelectedIndex() != -1) {
							EntidadBean cb = (EntidadBean) listaProveedores
									.getSelectedValue();
							DetalleCliente frm = new DetalleCliente(cb);
							frm.setLocationRelativeTo(null);
							frm.setVisible(true);
							_exit();
						}
					}
				});
			}
			{
				buttonSalir = new JButton();
				getContentPane().add(buttonSalir);
				buttonSalir.setText("Salir");
				buttonSalir.setBounds(135, 250, 111, 23);
				buttonSalir.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						_exit();
					}
				});
			}
			{

				listaProveedores = new JList(listModel);
				listaProveedores
						.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
				listaProveedores.setLayoutOrientation(JList.VERTICAL);
				listaProveedores.setVisibleRowCount(-1);

				JScrollPane listScroller = new JScrollPane(listaProveedores);
				listScroller.setBounds(27, 58, 331, 156);
				getContentPane().add(listScroller);
				for (EntidadBean eb : controller.ControllerPrincipal
						.getInstancia().obtenerProveedoresActivos()) {
					listModel.addElement(eb);
				}
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("Cuil - Razon Social - Condicion IVA");
				jLabel1.setBounds(40, 38, 310, 16);
			}
			{
				btnAlta = new JButton();
				getContentPane().add(btnAlta);
				btnAlta.setText("Alta");
				btnAlta.setBounds(39, 222, 124, 23);
				btnAlta.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						// AltaUsuario frm = new AltaUsuario();
						// frm.setLocationRelativeTo(null);
						// frm.setVisible(true);
						_exit();
					}
				});
			}

			pack();
			this.setSize(398, 319);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void _exit() {
		this.dispose();
	}
}
